import { Exclude } from 'class-transformer';
import { CompanyEntity } from 'src/company/entities/company.entity';
import { UserEntity } from 'src/user/entities/user.entity';
import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';

@Entity('record_company')
export class RecordCompanyEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ length: 36, comment: '用户id' })
  user_id: string;

  @Exclude()
  @ManyToOne(() => UserEntity)
  @JoinColumn({ name: 'user_id' })
  user: UserEntity;

  @Exclude()
  @Column({ length: 36, comment: '公司id' })
  company_id: string;

  @ManyToOne(() => CompanyEntity)
  @JoinColumn({ name: 'company_id' })
  company: CompanyEntity;

  @Column({ length: 255, comment: '公司名称' })
  name: string;

  @Column({
    type: 'tinyint',
    comment: '记录状态：1更新 0新增[默认]',
    default: 0,
  })
  is_update: number;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    comment: '记录时间',
  })
  create_time: Date;
}
